package gjtx6;

import java.util.Objects;

public class Member implements Comparable<Member> {
    private String number;
    private String name;
    private String phone;
    private int integral;
    private String password;

    public Member() {
    }

    public Member(String number, String name, String phone, int integral,String password) {
        this.number = number;
        this.name = name;
        this.phone = phone;
        this.integral = integral;
        this.password=password;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public int getIntegral() {
        return integral;
    }

    public void setIntegral(int integral) {
        if (integral>=0) {
            this.integral = integral;
            return;
        }
        this.integral=0;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "会员号：" + number +
                ",姓名：" + name +
                " 手机号：" + phone +
                " 积分：" + integral+
                "密码："+password;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Member member = (Member) o;
        return Objects.equals(number, member.number);
    }

    @Override
    public int hashCode() {
        return Objects.hash(number);
    }

    @Override
    public int compareTo(Member o) {
        return this.integral-o.integral;
    }
}
